package com.ruoyi.archives.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.archives.domain.SysTeacherRelatives;
import com.ruoyi.archives.service.ISysTeacherRelativesService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 教师亲属关系Controller
 * 
 * @author gzhankh
 * @date 2022-03-06
 */
@Api("老师亲属关系接口")
@RestController
@RequestMapping("/archives/teacher_relatives")
public class SysTeacherRelativesController extends BaseController
{
    @Autowired
    private ISysTeacherRelativesService sysTeacherRelativesService;

    /**
     * 查询教师亲属关系列表
     */
    @ApiOperation("查询教师亲属关系列表")
    @PreAuthorize("@ss.hasPermi('archives:teacher_relatives:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysTeacherRelatives sysTeacherRelatives)
    {
        startPage();
        List<SysTeacherRelatives> list = sysTeacherRelativesService.selectSysTeacherRelativesList(sysTeacherRelatives);
        return getDataTable(list);
    }

    /**
     * 导出教师亲属关系列表
     */
    @ApiOperation("导出教师亲属关系列表")
    @PreAuthorize("@ss.hasPermi('archives:teacher_relatives:export')")
    @Log(title = "教师亲属关系", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysTeacherRelatives sysTeacherRelatives)
    {
        List<SysTeacherRelatives> list = sysTeacherRelativesService.selectSysTeacherRelativesList(sysTeacherRelatives);
        ExcelUtil<SysTeacherRelatives> util = new ExcelUtil<SysTeacherRelatives>(SysTeacherRelatives.class);
        util.exportExcel(response, list, "教师亲属关系数据");
    }

    /**
     * 获取教师亲属关系详细信息
     */
    @ApiOperation("获取教师亲属关系详细信息")
    @PreAuthorize("@ss.hasPermi('archives:teacher_relatives:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(sysTeacherRelativesService.selectSysTeacherRelativesById(id));
    }

    /**
     * 新增教师亲属关系
     */
    @ApiOperation("新增教师亲属关系")
    @PreAuthorize("@ss.hasPermi('archives:teacher_relatives:add')")
    @Log(title = "教师亲属关系", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysTeacherRelatives sysTeacherRelatives)
    {
        return toAjax(sysTeacherRelativesService.insertSysTeacherRelatives(sysTeacherRelatives));
    }

    /**
     * 修改教师亲属关系
     */
    @ApiOperation("修改教师亲属关系")
    @PreAuthorize("@ss.hasPermi('archives:teacher_relatives:edit')")
    @Log(title = "教师亲属关系", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysTeacherRelatives sysTeacherRelatives)
    {
        return toAjax(sysTeacherRelativesService.updateSysTeacherRelatives(sysTeacherRelatives));
    }

    /**
     * 删除教师亲属关系
     */
    @ApiOperation("删除教师亲属关系")
    @PreAuthorize("@ss.hasPermi('archives:teacher_relatives:remove')")
    @Log(title = "教师亲属关系", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(sysTeacherRelativesService.deleteSysTeacherRelativesByIds(ids));
    }
}
